﻿@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment WebHostEnvironment
@{
    var currentController = ViewContext.RouteData?.Values["controller"]?.ToString();
    var currentAction = ViewContext.RouteData?.Values["action"]?.ToString();
    var customPageRouteName = ViewContext.RouteData?.Values["routeName"]?.ToString();
}

<!DOCTYPE html>
<html>
<head>
    <title>
        @(ViewBag?.TitlePrefix)@(null == ViewBag?.TitlePrefix ? string.Empty : " - ")@BlogConfig.GeneralSettings.SiteTitle
        <environment exclude="Production">
            (@WebHostEnvironment.EnvironmentName)
        </environment>
    </title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    @if (IsSectionDefined("keywords"))
    {
        @RenderSection("keywords", false)
    }
    else
    {
        <meta name="keywords" content="@Html.Raw(BlogConfig.GeneralSettings.MetaKeyword)" />
    }
    @RenderSection("meta", false)
    @if (IsSectionDefined("metadescription"))
    {
        @RenderSection("metadescription", false)
    }
    else
    {
        <meta name="description" content="@BlogConfig.GeneralSettings.MetaDescription" />
    }

    @if (!string.IsNullOrWhiteSpace(BlogConfig.AdvancedSettings.DNSPrefetchEndpoint))
    {
        <link rel="dns-prefetch" href="@BlogConfig.AdvancedSettings.DNSPrefetchEndpoint" />
    }
    <link rel="start" title="@BlogConfig.GeneralSettings.SiteTitle" href="~/" />
    <link rel="alternate" type="application/rss+xml" title="@BlogConfig.FeedSettings.RssTitle" href="~/rss" />
    <link type="application/opensearchdescription+xml" rel="search" title="@BlogConfig.GeneralSettings.SiteTitle" href="~/opensearch" />
    <partial name="_Favicons" />
    <link href="~/css/mooglade-css-bundle.min.css" rel="stylesheet" asp-append-version="true" />
    <script src="~/js/app/app-js-bundle.min.js" asp-append-version="true"></script>
    @RenderSection("head", false)
    <environment include="Production">
        @Html.Raw(JavaScriptSnippet.FullScript)
    </environment>
    <link href="~/css/theme/@BlogConfig.GeneralSettings.ThemeFileName" rel="stylesheet" asp-append-version="true" />
</head>
<body>
    <header class="ediblog-header">
        <nav id="moonglade-nav" class="navbar fixed-top navbar-expand-lg navbar-dark bg-moonglade-accent1">
            <div class="container">
                <div class="animbrand">
                    <a class="moonglade-logo navbar-brand animate" href="/">
                        @BlogConfig.GeneralSettings.LogoText
                    </a>
                </div>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#moonglade-navbar-content" aria-controls="moonglade-navbar-content" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="moonglade-navbar-content">
                    <ul class="navbar-nav mr-auto">
                        <li id="navbar-dropdown-post" class="nav-item @("Category" == currentController ? "dropdown active" : "dropdown")">
                            <a href="#" class="nav-link dropdown-toggle" role="button" data-toggle="dropdown">
                                <span class="icon-book"></span>
                                <strong>Categories</strong>
                            </a>
                            <cache expires-after="@TimeSpan.FromMinutes(60)">
                                @await Component.InvokeAsync("CategoryMenu")
                            </cache>
                        </li>

                        <li class="nav-item @(string.Compare("Tags", currentController, StringComparison.OrdinalIgnoreCase) == 0 ? "active" : null)">
                            <a asp-controller="Tags" asp-action="Index" class="nav-link">
                                <span class="icon-price-tag"></span>
                                <strong>Tags</strong>
                            </a>
                        </li>

                        <li class="nav-item @(string.Compare("Archive", currentController, StringComparison.OrdinalIgnoreCase) == 0 ? "active" : null)">
                            <a asp-controller="Archive" asp-action="Index" class="nav-link">
                                <span class="icon-folder"></span>
                                <strong>Archive</strong>
                            </a>
                        </li>
                        <li class="nav-item @(string.Compare("about", customPageRouteName, StringComparison.OrdinalIgnoreCase) == 0 ? "active" : null)">
                            <a asp-controller="CustomPage" asp-action="Index" asp-route-routeName="about" class="nav-link">
                                <span class="icon-star-full"></span>
                                <strong>About</strong>
                            </a>
                        </li>
                    </ul>
                    <form class="form-inline search-form my-2 my-lg-0" asp-controller="Search" asp-action="Index">
                        <input id="term"
                               class="form-control bg-transparent mr-sm-2"
                               type="search"
                               value=""
                               title="Search"
                               aria-label="Search"
                               placeholder="Search"
                               name="term"
                               maxlength="30">
                        <button class="btn btn-outline-light btn-search my-2 my-sm-0 d-none d-md-block" type="submit"><span class="icon-search"></span></button>
                        <button class="btn btn-block btn-success d-block d-sm-none mt-1" type="submit"><span class="icon-search"></span> Search</button>
                    </form>
                </div>
            </div>
        </nav>
    </header>

    @if (BlogConfig.ContentSettings.ShowCalloutSection)
    {
        <section class="call-out">
            @Html.Raw(BlogConfig.ContentSettings.CalloutSectionHtmlPitch)
        </section>
    }

    <div id="page-content" class="content">
        @if (null != ViewBag.ShowBloggerIntroInXS && ViewBag.ShowBloggerIntroInXS)
        {
            <section class="blogger-intro-mobile d-block d-sm-none">
                <div class="card-bkimg-container">
                    <img class="card-bkimg" alt="" src="@Url.Action("Avatar", "Assets")" />
                </div>
                <div class="blogger-intro-content">
                    <div class="row">
                        <div class="col-3">
                            <a asp-controller="CustomPage" asp-action="Index" asp-route-routeName="about">
                                <img src="@Url.Action("Avatar", "Assets")"
                                     alt="@BlogConfig.GeneralSettings.OwnerName"
                                     class="rounded-circle blogger-head-pic" />
                            </a>
                        </div>
                        <div class="col-9">
                            <h4 class="text-center">
                                @BlogConfig.GeneralSettings.ShortDescription
                            </h4>
                        </div>
                    </div>
                </div>
            </section>
        }
        @if (null != ViewBag.HideSideBar && ViewBag.HideSideBar)
        {
            @RenderBody()
        }
        else
        {
            <div class="container mt-4 mb-5">
                <div class="row">
                    <section class="col-lg-9 col-md-12">
                        @RenderBody()
                    </section>
                    <partial name="_Aside" />
                </div>
            </div>
        }
    </div>
    <div class="clearfix"></div>
    <partial name="_Footer" />

    @RenderSection("scripts", false)
</body>
</html>
